package azalea.mqtt.message.builder.impl;

import azalea.mqtt.message.utils.MsgUtils;

public class SubscribeDataImpl {
	
	/**
	 * 82 头 |0F 9+6=F 长度 |74 A2 00 00 ？| 09 长度| 6D 79 74 6F 70 69 63 2F 23  mytopic/# | 00 ？
	 * 82 0F 74 A2 00 00 09 6D 79 74 6F 70 69 63 2F 23 00  
	 * mytopic/# 
     * 90 04 74 A2 00 00  
	 */
	/**
	 * 
	 * 
	 * 
	 * @param msb
	 * @param lsb
	 * @param payload
	 * @param payloadLen
	 * @return
	 */
	public static byte[] subscribe(byte msb,byte lsb,byte[] payload,int payloadLen) {
		//TODO 
		return MsgUtils.commMsg(8,2, msb,lsb, payload, payloadLen);
	}
	public static byte[] suback(byte msb,byte lsb,byte[] payload,int payloadLen) {
		/**
|Bit        |7      |6      |5      |4      |3      |2      |1      |0
|byte 1     |MQTT Control Packet type (9)   |Reserved
|           |1      |0      |0      |1      |0      |0      |0      |0
|byte 2     |Remaining Length
		 */
		return MsgUtils.commMsg(9, msb,lsb, payload, payloadLen);
	}
	public static byte[] unsubscribe (byte msb,byte lsb,byte[] payload,int payloadLen) {
		return MsgUtils.commMsg(10, msb,lsb, payload, payloadLen);
	}
	public static byte[] unsuback (byte msb,byte lsb) {
		/**
|Bit        |7      |6      |5      |4      |3      |2      |1      |0
|byte 1     |MQTT Control Packet type (11)  |Reserved
|           |1      |0      |1      |1      |0      |0      |0      |0
|byte 2     |Remaining Length (2)
|           |0      |0      |0      |0      |0      |0      |1      |0
		 */
		return new byte[]{(byte)0b10110000,(byte)0b0000010,msb,lsb};
	}
}
